<template>
  <div>
    <a-card :bordered="false" style="margin-bottom: 10px;">
      <!-- 条件搜索 -->
      <div class="table-page-search-wrapper">
        <a-form :labelCol="labelCol" :wrapperCol="wrapperCol" ref="queryForm">
          <a-row :gutter="32">
            <a-col :span="6">
              <a-form-item label="供应商名称">
                <a-input v-model="queryParam.supplierName" placeholder="请输入供应商名称"/>
              </a-form-item>
            </a-col>
            <a-col>
              <span class="table-page-search-submitButtons" style="float: right;">
                <a-button type="primary" @click="handleQuery"><a-icon type="search" />查询</a-button>
                <a-button style="margin-left: 8px" @click="resetQuery"><a-icon type="redo" />重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card :bordered="false" class="table-card">
      <advance-table title="应付账款" :pagination="{
        current: queryParam.pageNum,
        pageSize: queryParam.pageSize,
        total: total,
        showSizeChanger: true,
        pageSizeOptions:pageSizeOptions,
        showLessItems: true,
        showQuickJumper: true,
        showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条，总计 ${total} 条`,
        onChange: changeSize,
        onShowSizeChange: onShowSizeChange
      }" tableKey="base-bizOrder-index-table" @change="handleTableChange" rowKey="id" @refresh="getList"
      :components="drag(columns)"
        :columns="columns" :data-source="dataList" :loading="loading" :format-conditions="true">
        
        <div class="table-operations" slot="button">
          <a-button type="primary" v-hasPermi="['biz:bizSupplierPayable:export']" :loading="downLoading"  @click='exportExcel'>
            <a-icon />导出
          </a-button>
        </div>
      </advance-table>
    </a-card>
  </div>
</template>
<script>
import { listBizSupplierPayable } from '@/api/biz/bizSupplierPayable'
import AdvanceTable from '@/components/pt/table/AdvanceTable'
import tableDragResizeMixin from '@/mixins/tableDragResizeMixin'
import listMixin from '@/mixins/listMixin';
export default {
  name: 'BizSupplierPayable',
  components: {
    AdvanceTable
  },
  mixins:[tableDragResizeMixin,listMixin],
  data() {
    return {
      showAddModal: false,
      // 遮罩层
      loading: true,
      title:'应付账款',
      listFunc:(param)=>listBizSupplierPayable(param),

      // 选中数组
      ids: [],
      // 选中的主键集合
      selectedRowKeys: [],
      // 选中的数据集合
      selectedRows: [],
      // 高级搜索 展开/关闭
      advanced: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // label的百分比
      labelCol: { span: 6 },
      // 内容区域的百分比
      wrapperCol: { span: 18 },
      // 表格数据
      dataList: [],
      // 查询参数
      queryParam: {
        pageNum: 1,
        pageSize: 11,
        supplierName: undefined
      },
      
      pageSizeOptions: ['11', '21', '31', '101', '201'],
      columns: [
        {
          title: '供应商名称',
          dataIndex:'supplierName',
          align: 'center'
        },
        {
          title: '总金额',
          dataIndex:'totalAmount',
          align: 'center'
        },
        {
          title: '已付金额',
          dataIndex:'payAmount',
          align: 'center'
        },
        {
          title: '未付金额',
          dataIndex:'hasAmount',
          align: 'center'
        },
        // {
        //   title: '预付金额',
        //   dataIndex:'advanceAmount',
        //   align: 'center'
        // }
      ]
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询销售单列表 */
    getList() {
      this.loading = true
      
      let param = this.getQueryParam()
      listBizSupplierPayable(param).then(response => {
        this.dataList = response.data.list
        this.total = response.data.total
        this.loading = false
        this.tableAddTotalRow(this.columns,this.dataList)
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParam.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParam = {
        pageNum: 1,
        pageSize: 10,
        supplierName: undefined

      }
      this.handleQuery()
    },
    /** 翻页操作 */
    onShowSizeChange(current, pageSize) {
      this.queryParam.pageSize = pageSize
      this.getList()
    },
    /** 翻页操作 */
    onSizeChange(current, size) {
      this.queryParam.pageNum = 1
      this.queryParam.pageSize = size
      this.getList()
    },
    /** 翻页操作 */
    changeSize(current, pageSize) {
      this.queryParam.pageNum = current
      this.queryParam.pageSize = pageSize
      this.getList()
    },
    /** 翻页操作 */
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
      this.ids = this.selectedRows.map(item => item.id)
      this.single = selectedRowKeys.length !== 1
      this.multiple = !selectedRowKeys.length
    },
    handleTableChange(pagination, filters, sorter) {
      if (sorter.field !== undefined && sorter.field !== null && sorter.field !== '') {
        this.queryParam.orderByColumn = 'a.' + sorter.field
        this.queryParam.isAsc = sorter.order
      }
      this.getList()
    }
  }
}
</script>
